﻿using System;
using System.Globalization;
using System.Text.RegularExpressions;
using System.Windows.Data;

namespace Red.Controls.Converters
{
    // When we use menu items as other elements (e.g buttons), if their captions contain underscores,
    // they are treated by the menu as shortcut markers - this converter will remove those shortcut markers
    public class IgnoreUnderscoresConverter : IValueConverter
    {
        public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
        {
            string s = value as string;

            return s != null ? Regex.Replace( s, "_", "" ) : value;
        }

        public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
        {
            throw new NotImplementedException();
        }
    }
}
